package cn.harperDog.reflect.allInterfaceImpl.entity;

import io.netty.channel.ChannelHandlerContext;

public interface IProcessor {
    /**
     * 处理消息
     * @param msg
     * @throws Exception
     */
    void process(String msg) throws Exception;


    /**
     * 获取事件类型
     * @return
     */
    String getType();


    /**
     * 获取连接的ip信息
     * @param ctx
     * @return
     */
    default String getIpFromChannelContext(ChannelHandlerContext ctx){

        String[] ipPort = ctx.channel().remoteAddress().toString().split(":");

        return ipPort[0].substring(1);

    }

}
